package com.xhu.water_supply.dto;

/**
 * 错误码参数列表
 */
public enum ResultEnum {
    SUCCESS("0", "成功"),
    FAIL("1", "失败"),
    COMMON_EXCEPTION("5", "系统异常"),
    FAIL_TOKEN_VERIFY("6", "Token验证无效！"),
    FAIL_TOKEN_EXP("7", "Token已过期！"),
    FAIL_PARAM("1001", "请求参数错误"),
    FAIL_LOGIN("1002", "登录失败"),
    FAIL_VERIFY("1003", "验证码错误"),
    FAIL_ACCOUNT_EXIST("1004", "账号已存在"),
    FAIL_ACCOUNT_NOT_EXIST("1005", "账号不存在"),
    FAIL_TIMESTAMP_NOT_NULL("1006", "时间戳不能为空"),
    FAIL_VISIT_SOURCE_NOT_NULL("1007", "访问来源不能为空"),
    FAIL_IMAGE_VERIFY("1008", "验证码错误"),
    FILE_NOT_LOGIN("2001", "未登录"),
    FILE_NOT_HAVE_PERMISSION("2002", "没有权限"),
    FAIL_ACCOUNT_LOCK("2003", "账号已被锁定"),
    FAIL_NOT_FIND_PAGE("3001", "找不到页面"),
    FAIL_TIMEOUT("3002", "请求超时"),
    FAIL_HAVE_DELETED("3003", "已被删除"),
    FAIL_HAVE_NOT_EXIST("3005", "数据不存在"),
    FAIL_REGISTER_SUCCESS("3006", "注册成功"),
    SUCCESS_ALL_ADMIN_INFO("4000", "成功查询全部信息"),
    SUCCESS_UPDATE_PASSWORD("4001", "修改密码成功"),
    FAIL_OLD_PASSWORD("4002", "旧密码错误"),
    FAIL_UPDATE_PASSWORD("4003", "修改密码错误"),
    SUCCESS_UPDATE_ADMIN_INFO("4004", "信息修改成功"),
    FAIL_UPDATE_ADMIN_INFO("4005", "信息修改错误"),
    SUCCESS_MODIFY_ADMIN_INFO("4006", "成功查询改用户信息"),
    SUCCESS_DELETE_ADMIN("4007","删除成功"),
    FAIL_DELETE_ADMIN("4008","删除失败"),
    SUCCESS_ADD_ADMIN("4009","添加成功"),
    FAIL_ADD_ADMIN("4010","添加失败"),
    FAIL_ADD_ACCOUNT_REPEAT("4011","账户重复"),
    SUCCESS_QUERY_ADMIN_INFO("4009","查询成功"),;
    String code;
    String msg;

    ResultEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }


    public static ResultEnum getByCode(String code) {
        if (code == null) {
            return COMMON_EXCEPTION;
        }
        for (ResultEnum outputEnum : ResultEnum.values()) {
            if (code.equals(outputEnum.code)) {
                return outputEnum;
            }
        }
        return COMMON_EXCEPTION;
    }
}
